/**
 * Created by admin on 2017/5/17.
 */
(function(){
    var tool={};
        //tool.httpUrl="http://192.168.1.24:9999";
        tool.httpUrl="http://106.14.237.207:9999";
        tool.header={
        public_key:'040CD66A84025B94CEAC3EC1B49C92D0',
        app_key:'ZQXQ-JSD',
        source:'1',
        client_id:'IMEI',
        channel:'tencent',
        app_version:'1.0.1',
        timestamp:'',
        signature:''
    };
    tool.ajax = function (key, headera, data, success) {
        $.ajax({
            url: key,
            data: data,
            dataType: 'json',
            type: 'POST',
            jsonpCallback: "successCallback",
            jsonp: "callback",
            async: true,
            headers: headera,
            success: success,
            error:function (e) {
            console.log(e);
    }
        });
    };
    tool.GetQueryString = function (key) {
        // key为url变量名称
        var urlGets = location.search.substr(1);
        if (urlGets.length > 0) {
            start = urlGets.indexOf(key + '=');
            if (start != -1) {
                start = start + key.length + 1;
                end = urlGets.indexOf('&', start);
                if (end == -1) {
                    end = urlGets.length
                }
                return decodeURIComponent(urlGets.substring(start, end));
            }
        }
        return "";
    };
    tool.getencodeURIComponent=function(dataContact) {
        var c;
        var a = [];
        $.each(dataContact, function(key, val) {
            a[a.length] = key;
        });
        a.sort();
        $.each(a, function(i, key) {
            c += encodeURI("&"+key+"="+dataContact[key]) ;
            //c += "&"+key+"="+dataContact[key];
        });
        paramsStr = c.split("undefined&")[1];
        var reg=/,/g;
        var regs=/:/g;
        paramsStr=paramsStr.replace(reg,'%2C');
        paramsStr=paramsStr.replace(regs,'%3A');
        return paramsStr;
    };
     tool.getparamsStr=function(dataContact) {
        var c;
        var a = [];
        $.each(dataContact, function (key, val) {
            a[a.length] = key;
        });
        a.sort();
        $.each(a, function (i, key) {
            c += encodeURI("&" + key + "=" + dataContact[key]);
            //c += "&"+key+"="+dataContact[key];
        });
        paramsStr = c.split("undefined&")[1];
        return paramsStr;
    };




        window.tool=tool;
})();